package com.bupt.ilink.service.bailian.impl;

import com.aliyun.bailian20231229.models.ListFileResponse;
import com.aliyun.tea.TeaException;
import org.springframework.stereotype.Service;

@Service
public class ListFileService {
/**
 * 返回格式
 *{
 *   "Status": "200",
 *   "Message": "",
 *   "RequestId": "CAFB0482-3134-55DB-A7C8-C0C1541A6839",
 *   "Data": {
 *     "TotalCount": 3,
 *     "FileList": [
 *       {
 *         "CategoryId": "cate_ff4dacacc84f429a881803622dd7ce41_10249160",
 *         "Status": "PARSE_SUCCESS",
 *         "FileType": "pdf",
 *         "CreateTime": "2024-08-09 14:33:27",
 *         "FileName": "Codex2107.03374.pdf",
 *         "FileId": "file_493bb69ac0584dd2a2504ed9398788d0_10249160",
 *         "SizeInBytes": 1885177,
 *         "Parser": "DASHSCOPE_DOCMIND"
 *       },
 *       {
 *         "CategoryId": "cate_ff4dacacc84f429a881803622dd7ce41_10249160",
 *         "Status": "PARSE_SUCCESS",
 *         "FileType": "pdf",
 *         "CreateTime": "2024-08-09 14:33:27",
 *         "FileName": "用大模型找prompt2309.03409.pdf",
 *         "FileId": "file_e9a99f95147b4289888c766046369f1f_10249160",
 *         "SizeInBytes": 1592683,
 *         "Parser": "DASHSCOPE_DOCMIND"
 *       },
 *       {
 *         "CategoryId": "cate_ff4dacacc84f429a881803622dd7ce41_10249160",
 *         "Status": "PARSE_SUCCESS",
 *         "FileType": "txt",
 *         "CreateTime": "2024-08-08 23:29:59",
 *         "FileName": "protein.txt",
 *         "FileId": "file_8ea4a23089b14f408e6663eb6ebdcb24_10249160",
 *         "SizeInBytes": 2470,
 *         "Parser": "DASHSCOPE_DOCMIND"
 *       }
 *     ],
 *     "MaxResults": 20,
 *     "HasNext": false
 *   },
 *   "Code": "Success",
 *   "Success": true
 * }
 **/
    public ListFileResponse listfile(com.aliyun.bailian20231229.Client client, String CategoryId, String WorkspaceId) throws Exception {
        com.aliyun.bailian20231229.models.ListFileRequest listFileRequest = new com.aliyun.bailian20231229.models.ListFileRequest()
                .setCategoryId(CategoryId);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        java.util.Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            return client.listFileWithOptions(WorkspaceId, listFileRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new TeaException(error.getMessage(), error);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
            throw new Exception(error.getMessage());
        }
    }
}
